/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainWindow.java
 *
 * Created on 25/01/2012, 20:47:43
 */
package com.csm.sim2k11.frontend;

import com.csm.sim2k11.simulator.Configuration;
import com.csm.sim2k11.simulator.Simulator;
import javax.swing.ImageIcon;
import javax.swing.SwingWorker;
import javax.swing.table.TableModel;

/**
 *
 * @author santi
 */
public class MainWindow extends javax.swing.JFrame {

    SwingWorker simulation;
    
    /** Creates new form MainWindow */
    public MainWindow() {
        this.setIconImage(new ImageIcon(getClass().getResource("/icons/64/sim-icon_64.png")).getImage());
        initComponents();
        txtCantSimulations.setText(String.valueOf(Configuration.getCantSimulations()));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar = new javax.swing.JToolBar();
        btnSimulate = new javax.swing.JButton();
        btnStopSimulation = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        lblCantSimulations = new javax.swing.JLabel();
        txtCantSimulations = new javax.swing.JTextField();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        btnConfig = new javax.swing.JButton();
        btnHelp = new javax.swing.JButton();
        btnAbout = new javax.swing.JButton();
        jSplitPane = new javax.swing.JSplitPane();
        pnlLeftSide = new javax.swing.JPanel();
        btnStadistics = new javax.swing.JButton();
        pnlStadistics = new javax.swing.JPanel();
        lblCantClients = new javax.swing.JLabel();
        lblActualCantClients = new javax.swing.JLabel();
        lblClientsLost = new javax.swing.JLabel();
        lblActualClientsLost = new javax.swing.JLabel();
        lblClientsLostPercentage = new javax.swing.JLabel();
        lblActualClientLostPercentage = new javax.swing.JLabel();
        lblClientsPercentage = new javax.swing.JLabel();
        lblActualClientsPercentage = new javax.swing.JLabel();
        lblTime = new javax.swing.JLabel();
        lblActualTime = new javax.swing.JLabel();
        pnlMemory = new javax.swing.JPanel();
        progMemory = new javax.swing.JProgressBar();
        jProgressBar = new javax.swing.JProgressBar();
        tableScrollPane = new javax.swing.JScrollPane();
        tableSimulation = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SimSoft - 1.1.2 RC");

        jToolBar.setFloatable(false);
        jToolBar.setRollover(true);
        jToolBar.setToolTipText("");

        btnSimulate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/control_play_blue.png"))); // NOI18N
        btnSimulate.setMnemonic('s');
        btnSimulate.setToolTipText("Inicial la Simulación");
        btnSimulate.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/control_play.png"))); // NOI18N
        btnSimulate.setFocusable(false);
        btnSimulate.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSimulate.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnSimulate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSimulateActionPerformed(evt);
            }
        });
        jToolBar.add(btnSimulate);

        btnStopSimulation.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/control_stop_blue.png"))); // NOI18N
        btnStopSimulation.setMnemonic('p');
        btnStopSimulation.setToolTipText("Cancelar la Simulación");
        btnStopSimulation.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/control_stop.png"))); // NOI18N
        btnStopSimulation.setEnabled(false);
        btnStopSimulation.setFocusable(false);
        btnStopSimulation.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnStopSimulation.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnStopSimulation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnStopSimulationActionPerformed(evt);
            }
        });
        jToolBar.add(btnStopSimulation);
        jToolBar.add(jSeparator2);

        lblCantSimulations.setText("Simulaciones:");
        jToolBar.add(lblCantSimulations);

        txtCantSimulations.setText("1000");
        txtCantSimulations.setToolTipText("Cantidad de iteraciones a simular");
        jToolBar.add(txtCantSimulations);
        jToolBar.add(jSeparator1);

        btnConfig.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/cog.png"))); // NOI18N
        btnConfig.setMnemonic('c');
        btnConfig.setToolTipText("Configuración");
        btnConfig.setFocusable(false);
        btnConfig.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnConfig.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnConfig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConfigActionPerformed(evt);
            }
        });
        jToolBar.add(btnConfig);

        btnHelp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/help.png"))); // NOI18N
        btnHelp.setMnemonic('h');
        btnHelp.setToolTipText("Ayuda");
        btnHelp.setFocusable(false);
        btnHelp.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnHelp.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnHelp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHelpActionPerformed(evt);
            }
        });
        jToolBar.add(btnHelp);

        btnAbout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/information.png"))); // NOI18N
        btnAbout.setMnemonic('a');
        btnAbout.setToolTipText("Acerca de SimSoft 1.1.2");
        btnAbout.setFocusable(false);
        btnAbout.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAbout.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnAbout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAboutActionPerformed(evt);
            }
        });
        jToolBar.add(btnAbout);

        jSplitPane.setDividerLocation(240);

        btnStadistics.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/chart_bar.png"))); // NOI18N
        btnStadistics.setMnemonic('g');
        btnStadistics.setText("Estadísticas");
        btnStadistics.setEnabled(false);
        btnStadistics.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnStadisticsActionPerformed(evt);
            }
        });

        pnlStadistics.setBorder(javax.swing.BorderFactory.createTitledBorder("Estadísticas:"));

        lblCantClients.setText("Cant. de Clientes Atendidos:");

        lblActualCantClients.setFont(new java.awt.Font("Tahoma", 1, 14));
        lblActualCantClients.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblActualCantClients.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/user.png"))); // NOI18N
        lblActualCantClients.setText("0");

        lblClientsLost.setText("Cant. de Clientes Perdidos:");

        lblActualClientsLost.setFont(new java.awt.Font("Tahoma", 1, 14));
        lblActualClientsLost.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblActualClientsLost.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/16/user_go.png"))); // NOI18N
        lblActualClientsLost.setText("0");

        lblClientsLostPercentage.setText("% Clientes Perdidos:");

        lblActualClientLostPercentage.setFont(new java.awt.Font("Tahoma", 1, 14));
        lblActualClientLostPercentage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblActualClientLostPercentage.setText("0%");

        lblClientsPercentage.setText("% Clientes Atendidos:");

        lblActualClientsPercentage.setFont(new java.awt.Font("Tahoma", 1, 14));
        lblActualClientsPercentage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblActualClientsPercentage.setText("0%");

        lblTime.setText("Tiempo de Simulación:");

        lblActualTime.setFont(new java.awt.Font("Tahoma", 1, 14));
        lblActualTime.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblActualTime.setText("0s");

        javax.swing.GroupLayout pnlStadisticsLayout = new javax.swing.GroupLayout(pnlStadistics);
        pnlStadistics.setLayout(pnlStadisticsLayout);
        pnlStadisticsLayout.setHorizontalGroup(
            pnlStadisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlStadisticsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlStadisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblActualClientsPercentage, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                    .addComponent(lblActualClientLostPercentage, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                    .addGroup(pnlStadisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(lblCantClients, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblActualCantClients, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblClientsLost)
                        .addComponent(lblActualClientsLost, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblClientsPercentage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(lblClientsLostPercentage)
                    .addComponent(lblActualTime, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                    .addComponent(lblTime))
                .addContainerGap())
        );
        pnlStadisticsLayout.setVerticalGroup(
            pnlStadisticsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlStadisticsLayout.createSequentialGroup()
                .addComponent(lblCantClients)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblActualCantClients)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblClientsLost)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblActualClientsLost)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblClientsPercentage)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblActualClientsPercentage)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblClientsLostPercentage)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblActualClientLostPercentage)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblTime)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblActualTime))
        );

        pnlMemory.setBorder(javax.swing.BorderFactory.createTitledBorder("Estado de la Memoria:"));

        progMemory.setToolTipText("Estado actual de la memoria");
        progMemory.setEnabled(false);
        progMemory.setStringPainted(true);

        javax.swing.GroupLayout pnlMemoryLayout = new javax.swing.GroupLayout(pnlMemory);
        pnlMemory.setLayout(pnlMemoryLayout);
        pnlMemoryLayout.setHorizontalGroup(
            pnlMemoryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(progMemory, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)
        );
        pnlMemoryLayout.setVerticalGroup(
            pnlMemoryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlMemoryLayout.createSequentialGroup()
                .addComponent(progMemory, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jProgressBar.setStringPainted(true);

        javax.swing.GroupLayout pnlLeftSideLayout = new javax.swing.GroupLayout(pnlLeftSide);
        pnlLeftSide.setLayout(pnlLeftSideLayout);
        pnlLeftSideLayout.setHorizontalGroup(
            pnlLeftSideLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnlStadistics, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(pnlMemory, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(pnlLeftSideLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlLeftSideLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jProgressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                    .addComponent(btnStadistics, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE))
                .addContainerGap())
        );
        pnlLeftSideLayout.setVerticalGroup(
            pnlLeftSideLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlLeftSideLayout.createSequentialGroup()
                .addComponent(pnlStadistics, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlMemory, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 69, Short.MAX_VALUE)
                .addComponent(btnStadistics)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jSplitPane.setLeftComponent(pnlLeftSide);

        tableScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        tableScrollPane.setAutoscrolls(true);

        tableSimulation.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Orden", "Reloj", "Evento", //Datos basicos
                "Prox. Llegada", "rnd", "Cant. Clientes", //Datos de Llegada
                "Cola de Espera", //Cola de Espera del restaurant
                "Estado M1", "rnd C1", "Menu C1", "rnd C2", "Menu C2",//Datos de Mesa 1
                "rnd C3", "Menu C3", "rnd C4", "Menu C4", "rnd Comida",
                "t Comida", "Prox. Fin M1",
                "Estado M2", "rnd C1", "Menu C1", "rnd C2", "Menu C2",//Datos de Mesa 2
                "rnd C3", "Menu C3", "rnd C4", "Menu C4", "rnd Comida",
                "t Comida", "Prox. Fin M2",
                "Estado M3", "rnd C1", "Menu C1", "rnd C2", "Menu C2",//Datos de Mesa 3
                "rnd C3", "Menu C3", "rnd C4", "Menu C4", "rnd Comida",
                "t Comida", "Prox. Fin M3",
                "Estado M4", "rnd C1", "Menu C1", "rnd C2", "Menu C2",//Datos de Mesa 4
                "rnd C3", "Menu C3", "rnd C4", "Menu C4", "rnd Comida",
                "t Comida", "Prox. Fin M4",
                "Estado M5", "rnd C1", "Menu C1", "rnd C2", "Menu C2",//Datos de Mesa 5
                "rnd C3", "Menu C3", "rnd C4", "Menu C4", "rnd Comida",
                "t Comida", "Prox. Fin M5",
                "Estado M6", "rnd C1", "Menu C1", "rnd C2", "Menu C2",//Datos de Mesa 6
                "rnd C3", "Menu C3", "rnd C4", "Menu C4", "rnd Comida",
                "t Comida", "Prox. Fin M6"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false,false, false, false, false
                , false, false,false, false, false, false, false, false, false, false
                , false, false,false, false, false, false, false, false, false, false
                , false, false,false, false, false, false, false, false, false, false
                , false, false,false, false, false, false, false, false, false, false
                , false, false,false, false, false, false, false, false, false, false
                , false, false,false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tableSimulation.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tableSimulation.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        tableSimulation.getTableHeader().setReorderingAllowed(false);
        tableScrollPane.setViewportView(tableSimulation);

        jSplitPane.setRightComponent(tableScrollPane);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar, javax.swing.GroupLayout.DEFAULT_SIZE, 1065, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1053, Short.MAX_VALUE)
                .addGap(12, 12, 12))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSplitPane, javax.swing.GroupLayout.DEFAULT_SIZE, 483, Short.MAX_VALUE)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-1065)/2, (screenSize.height-554)/2, 1065, 554);
    }// </editor-fold>//GEN-END:initComponents

    private void btnConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfigActionPerformed
        new ConfigurationWindow().setVisible(true);
    }//GEN-LAST:event_btnConfigActionPerformed

private void btnSimulateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSimulateActionPerformed
    simulation = new Simulator(this);
    simulation.execute();
}//GEN-LAST:event_btnSimulateActionPerformed

private void btnStopSimulationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStopSimulationActionPerformed
    simulation.cancel(false);
}//GEN-LAST:event_btnStopSimulationActionPerformed

    private void btnHelpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHelpActionPerformed
    new HelpWindow().setVisible(true);
    }//GEN-LAST:event_btnHelpActionPerformed

    private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed
    new AboutWindow().setVisible(true);
    }//GEN-LAST:event_btnAboutActionPerformed

private void btnStadisticsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStadisticsActionPerformed
    new StadisticsWindow(Configuration.getHistoricResults()).setVisible(true);
}//GEN-LAST:event_btnStadisticsActionPerformed

    public void setProgress(int progress)
    {
        jProgressBar.setValue(progress);
        jProgressBar.setString(progress+"%");
    }
    
    public void simulationDone(int totalClients, int totalLostClients, double timeElapsed)
    {
        jProgressBar.setString("Simulación Terminada!");
        lblActualCantClients.setText(" "+totalClients);
        lblActualClientsLost.setText(" "+totalLostClients); 
        int total= totalClients + totalLostClients;
        lblActualClientsPercentage.setText(
                (int)(((double)totalClients/total)*100)+"%");
        lblActualClientLostPercentage.setText(
                (int)(((double)totalLostClients/total)*100)+"%");
        lblActualTime.setText(timeElapsed+"s");
        simulationFinished();
    }
    
    public void simulationCanceled()
    {
        jProgressBar.setString("Simulación Cancelada!");
        lblActualCantClients.setText("0");
        lblActualClientsLost.setText("0"); 
        lblActualClientsPercentage.setText("0%");
        lblActualClientLostPercentage.setText("0%");
        simulationFinished();
    }
    
    private void simulationFinished()
    {
        btnSimulate.setEnabled(true);
        btnStopSimulation.setEnabled(false);
        btnHelp.setEnabled(true);
        btnAbout.setEnabled(true);
        btnStadistics.setEnabled(true);
        txtCantSimulations.setEnabled(true); 
        btnConfig.setEnabled(true);
        progMemory.setValue(0);
        progMemory.setEnabled(false);
    }

    public void simulationStarted() throws NumberFormatException {
        btnSimulate.setEnabled(false);
        btnStopSimulation.setEnabled(true);
        btnConfig.setEnabled(false);
        btnHelp.setEnabled(false);
        btnAbout.setEnabled(false);
        btnStadistics.setEnabled(false);
        txtCantSimulations.setEnabled(false);
        progMemory.setEnabled(true);
        jProgressBar.setValue(0);
        jProgressBar.setString("");
        Configuration.setCantSimulations(Integer.valueOf(
                txtCantSimulations.getText()));
    }
    
    public void updateTable(TableModel model)
    {
        tableSimulation.setModel(model);
        tableSimulation.repaint();
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAbout;
    private javax.swing.JButton btnConfig;
    private javax.swing.JButton btnHelp;
    private javax.swing.JButton btnSimulate;
    private javax.swing.JButton btnStadistics;
    private javax.swing.JButton btnStopSimulation;
    private javax.swing.JProgressBar jProgressBar;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JSplitPane jSplitPane;
    private javax.swing.JToolBar jToolBar;
    private javax.swing.JLabel lblActualCantClients;
    private javax.swing.JLabel lblActualClientLostPercentage;
    private javax.swing.JLabel lblActualClientsLost;
    private javax.swing.JLabel lblActualClientsPercentage;
    private javax.swing.JLabel lblActualTime;
    private javax.swing.JLabel lblCantClients;
    private javax.swing.JLabel lblCantSimulations;
    private javax.swing.JLabel lblClientsLost;
    private javax.swing.JLabel lblClientsLostPercentage;
    private javax.swing.JLabel lblClientsPercentage;
    private javax.swing.JLabel lblTime;
    private javax.swing.JPanel pnlLeftSide;
    private javax.swing.JPanel pnlMemory;
    private javax.swing.JPanel pnlStadistics;
    private javax.swing.JProgressBar progMemory;
    private javax.swing.JScrollPane tableScrollPane;
    private javax.swing.JTable tableSimulation;
    private javax.swing.JTextField txtCantSimulations;
    // End of variables declaration//GEN-END:variables

    public void updateMemoryState (long totalMemory, long freeMemory)   
    {
        progMemory.setValue((int)((double)freeMemory/totalMemory*100));
    }    
}
